package com.big.app.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.big.app.dao.GuanZhuDao;
import com.big.app.entity.GuanZhu;
import com.big.app.service.intf.GuanZhuService;
import com.big.app.vo1.R;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class GuanZhuImpl implements GuanZhuService {

    @Resource
    private GuanZhuDao dao;
    @Override
    public R all() {
        return new R(200,"ok",dao.selectList(new QueryWrapper<GuanZhu>().eq("gzusers","123")));
    }

    @Override
    public R insert(GuanZhu guanZhu) {
        guanZhu.setGzusers("123");
        guanZhu.setGzimg("http://kqoss.oss-cn-beijing.aliyuncs.com/tp5.jpg?Expires=1744984789&OSSAccessKeyId=LTAI5t6DuENqcjTYDCsppyGg&Signature=%2F12Om4fTOoG8dirW%2FqU6%2BDQr%2Bp4%3D");
        return new R(200,"ok",dao.insert(guanZhu));
    }

    @Override
    public R delete(GuanZhu guanZhu) {
        int i = dao.deleteById(guanZhu);

        if (i==1){
            return new R(200,"ok",null);
        }else {
            return new R(400,"false",null);
        }
    }

    @Override
    public R exit(String gzuser) {
        GuanZhu one = dao.selectOne(new QueryWrapper<GuanZhu>().eq("gzuser", gzuser));
        System.out.println(one);
        if (one==null){
            return new R(400,"false",null);
        }else {
            return new R(200,"ok",one);
        }
    }
}
